﻿using System.Web;
using FluentNHibernate.Cfg.Db;
using NHibernate.Cfg;
using SalesManager.Data.Catalogs;
using SalesManager.Logic.Models;
using SalesManager.Logic.Repositories;

namespace SalesManager.Web
{
    public class RepositoryProviderConfiguration : IRepositoryProviderConfiguration
    {
        public User GetUser()
        {
            return HttpContext.Current.Session["User"] as User;
        }

        public IPersistenceConfigurer PersistenceConfigurerGenerator(ICatalog catalog)
        {
            return MsSqlConfiguration.MsSql2008
                .ConnectionString(c => c.FromConnectionStringWithKey(catalog.Name));
        }

        public void ExposeConfiguration(Configuration configuration)
        {
        }
    }
}